package com.qf.fc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.qf.fc.entity.Address;
import com.qf.fc.service.AddressService;
import com.qf.fc.vo.R;

import lombok.RequiredArgsConstructor;

@RestController 
@RequestMapping("/api/addresses/")
@RequiredArgsConstructor
public class AddressController {
    @Autowired
    private AddressService service;

    @GetMapping("{uid}")
    public R queryByUid(@PathVariable String uid) {
        Integer uidInt = Integer.parseInt(uid);
        return R.ok(service.selectByUid(uidInt));
    }


    @PostMapping("new")
    public R add(@RequestBody Address address) {
        System.out.println("address:"+address);
        return R.ok(service.add(address));
    }
}
